package com.gec.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gec.model.system.ITripService;
import com.gec.model.system.ITripServiceOrder;
import com.gec.model.vo.ITripServiceOrderVo;
import com.gec.model.vo.ITripServiceVo;
import com.gec.system.common.Result;
import com.gec.system.service.ITripServiceOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户套餐订单表 前端控制器
 * </p>
 *
 * @author dafei
 * @since 2024-01-22
 */
@Api(tags = "套餐订单管理")
@RestController
@RequestMapping("/system/itrServiceOrder")
public class ITripServiceOrderController {

    @Autowired
    private ITripServiceOrderService iTripServiceOrderService;

    // 分页 + 查询
    @ApiOperation("套餐订单分页查询")
    @GetMapping("/{page}/{limit}")
    public Result findRoleByPageQuery(@PathVariable Long page,
                                      @PathVariable Long limit,
                                      ITripServiceOrderVo iTripServiceOrderVo)
    {
        IPage<ITripServiceOrder> page1 = new Page<>(page,limit);
        page1 =   this.iTripServiceOrderService.selectPage(page1,iTripServiceOrderVo);
        return Result.ok(page1);
    }

//    @ApiOperation("添加套餐订单")
//    @PostMapping("/addServiceOrder")
//    public Result addServiceOrder(@RequestBody ITripServiceOrder iTripServiceOrder){
//        this.iTripServiceOrderService.save(iTripServiceOrder);
//        return Result.ok();
//    }

    @ApiOperation("根据id去查询套餐订单")
    // 根据id去查询菜单
    @GetMapping("/findNodeById/{id}")
    public Result findNodeById(@PathVariable Long id){
        ITripServiceOrder iTripServiceOrder = this.iTripServiceOrderService.getById(id);
        return Result.ok(iTripServiceOrder);
    }

    @ApiOperation(value = "修改套餐订单")
    @PostMapping("/updateITripServiceOrder")
    public Result updateById(@RequestBody ITripServiceOrder iTripServiceOrder) {
        iTripServiceOrderService.updateById(iTripServiceOrder);
        return Result.ok();
    }

    @ApiOperation(value = "删除套餐订单")
    @DeleteMapping("/removeITripServiceOrder/{id}")
    public Result removeITripServiceOrder(@PathVariable Long id) {
        iTripServiceOrderService.removeById(id);
        return Result.ok();
    }


}

